package com.iocaop.uaa.rest;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserResource {

    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }
    @GetMapping("/name")
    public String getName(){
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }

    @GetMapping("/auth")
    public Authentication getAuthentication(){
        return SecurityContextHolder.getContext().getAuthentication();
    }

    @GetMapping("/auth1")
    public Authentication getAuthentication(Authentication authentication){
        return authentication;
    }
}
